﻿using System;
using System.Collections.Generic;
using System.Text;
using Memcached.ClientLibrary;
using System.Collections;

namespace Zhuang.Utility.Memcached
{
    public static class MemcachedHelper
    {
        private static MemcachedClient mc;
        private static String[] servers=null;
        static MemcachedHelper()
        {
            
            if(servers ==null)
            {
                servers[0] = "127.0.0.1:11211";
            }

            // initialize the pool for memcached servers
            SockIOPool pool = SockIOPool.GetInstance("test");
            pool.SetServers(servers);
            pool.Initialize();
            mc = new MemcachedClient();
            mc.PoolName = "test";
            mc.EnableCompression = false;

        }

        public static bool Set(string key, object value, DateTime expiry)
        {
            return mc.Set(key, value, expiry);
        }

        public static object Get(string key)
        {
            return mc.Get(key);
        }
    }
}
